/**
 * @info    (AbstractController Klasse tbv. V&K simulatie, neemt methode in zich op, welke hergebruikt kunnen worden)
 * @author  (Veenstra Stephan, Bruins Marc, Jansma Michel) 
 * @version (2012.11.14)
 */

package controller;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.HashMap;

import runner.*;
import model.*;

public abstract class AbstractController {

	protected SimulatorRunner simulator;
	protected HashMap<String, JComponent> params;

	public AbstractController(SimulatorRunner simulator) {
		// Instantie variabelen initialiseren
		this.simulator = simulator;
		this.setParams();
	}

	/********************************************
	 * EVENT HANDLER PARAMS DATA START
	 *******************************************/

	protected HashMap<String, JComponent> getParams() {
		return this.params;
	}

	private void setParams() {
		this.params = new HashMap<String, JComponent>();
	}
	
	protected void addParam(String name, JComponent param) {
		this.getParams().put(name, param);
	}
	
	protected void clearAllParams() {
		this.getParams().clear();
	}

	/********************************************
	 * EVENT HANDLER PARAMS DATA END
	 *******************************************/
	

	/********************************************
	 * EVENT HANDLER DATA START
	 *******************************************/
	
	protected EventHandler getEventHandler(String handler) {
		return new EventHandler(this.simulator, handler, this.getParams());
	}

	/********************************************
	 * EVENT HANDLER DATA END
	 *******************************************/
}
